﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Mmht.DB;

namespace Mmht.BT
{
    public class StudentBT
    {
        StudentDB st = new StudentDB();
        /// <summary>
        /// 根据账号返回用户信息
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public DataTable FindByAccount(string account)
        {
            return st.FindByAccount(account);
        }

        public DataRow FindById(int id)
        {
            return st.FindById(id);
        }

        public bool checkAccountExist(string account)
        {
            DataTable dt = this.FindByAccount(account);
            if (dt == null)
            {
                return false;
            }
            if (dt.Rows.Count == 0)
            {
                return false;
            }
            return true;
        }

        /// <summary>
        /// 添加新用户
        /// </summary>
        /// <param name="account"></param>
        /// <param name="password"></param>
        /// <param name="created_by"></param>
        /// <returns></returns>
        public bool InsertStudent(string account, string password, string created_by)
        {
            return st.InsertStudent(account, password, created_by);
        }
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <returns></returns>
        public bool UpdateStudent(int studentId, string name, string password,
                                  string email, string phone)
        {
            //TODO
            return st.UpdateStudent(studentId ,name,password,email,phone );
        }
        public DataTable FindStudent() 
        {
            return st.FindStudent();
        }
        public bool DelStudent(int id) 
        {
            return st.DelStudent(id);
        }

        public bool DelAllStudent()
        {
            return st.DelAllStudent();
        }
    }
}
